import axios from "axios";
import storage from "../utils/storage";

const url = "https://jishuba.cn/wp-json/wx/v1/get-user"; 
const authService = {
    async getWxUser() {
        try {
            const response = await axios.get(url);
            return response.data;
        } catch (error) {
            console.error("Error fetching user data:", error);
            throw error;
        }
    },
    getUser() {
        try {
            const user = storage.get("user");
            return user;
        } catch (error) {
            console.error("Error fetching user data:", error);
            throw error;
        }
    },
    setUser(user:any) {
        try {
            storage.set("user", user);
        } catch (error) {
            console.error("Error fetching user data:", error);
            throw error;
        }
    }
}

export default authService;